package by.exposit.service;

import by.exposit.dao.PocketDAO;
import by.exposit.dao.entity.PocketEntity;
import by.exposit.domain.Pocket;
import org.dozer.DozerBeanMapperSingletonWrapper;
import org.dozer.Mapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class PocketServiceImpl implements PocketService{

    @Autowired
    private PocketDAO pocketDAO;

    @Override
    public void savePocket(Pocket pocket) {
        Mapper mapper = DozerBeanMapperSingletonWrapper.getInstance();
        pocketDAO.save(mapper.map(pocket, PocketEntity.class));
    }

    @Override
    public void donateForPocket(long pocketId, long amountOfMoney) {
        pocketDAO.donateForPocket(pocketId,amountOfMoney);
    }

    @Override
    public void remove(Long pocketId) {
        pocketDAO.remove(pocketId);
    }
}
